﻿CREATE TABLE [PR].[PriceInfo] (
    [Id]           INT           IDENTITY (1, 1) NOT NULL,
    [ContragentId] INT           NOT NULL,
    [Loaded]       SMALLDATETIME NOT NULL,
    [PriceDate]    SMALLDATETIME NOT NULL,
    [Note]         VARCHAR (250) NULL,
    [MD]           DATETIME      CONSTRAINT [DF__PriceInfo__MD__1DF06171] DEFAULT (getdate()) NOT NULL,
    [MW]           VARCHAR (50)  CONSTRAINT [DF__PriceInfo__MW__1EE485AA] DEFAULT (suser_sname()) NOT NULL,
    CONSTRAINT [PK_PriceInfo] PRIMARY KEY CLUSTERED ([Id] DESC),
    CONSTRAINT [FK_PriceInfo_Contragents] FOREIGN KEY ([ContragentId]) REFERENCES [CA].[Contragents] ([Id]) ON DELETE CASCADE NOT FOR REPLICATION
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Дата/время загрузки прайса', @level0type = N'SCHEMA', @level0name = N'PR', @level1type = N'TABLE', @level1name = N'PriceInfo', @level2type = N'COLUMN', @level2name = N'Loaded';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Дата прайса', @level0type = N'SCHEMA', @level0name = N'PR', @level1type = N'TABLE', @level1name = N'PriceInfo', @level2type = N'COLUMN', @level2name = N'PriceDate';

